package engine.newUi
{
	import com.greensock.TweenLite;
	import com.greensock.easing.Elastic;
	
	import engine.GameData;
	import engine.data.BindManage;
	import engine.data.ModelLocator;
	import engine.data.Record;
	import engine.data.RoleVo;
	import engine.event.SoundEvent;
	import engine.flag.PlayerActionFlag;
	import engine.logic.LogSendLogic;
	import engine.logic.McPool;
	import engine.logic.SceneTransfer;
	import engine.logic.event.LogicEvent;
	import engine.logic.login.PlayCDTimerLogic;
	import engine.net.event.CustomMsgEvent;
	import engine.net.messages.CustomToClientFlag;
	import engine.net.messages.CustomToServerFlag;
	import engine.net.mgr.SystemSender;
	import engine.scene.SceneChangeManager;
	import engine.scene.player.MoveAction;
	import engine.tip.TipsMainLogic;
	import engine.ui.lite.BaseUI;
	
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.geom.Point;
	import flash.media.ID3Info;
	import flash.utils.Dictionary;
	import flash.utils.setTimeout;
	
	import newx.StageInfo;
	import newx.com.ResManager;
	import newx.com.config.StaticIni;
	import newx.com.control.text.NxLabel;
	
	/**
	 *参加活动快捷入口 
	 * @author yanghr
	 * 
	 */
	public class ActivitesGroupLogic
	{
		private static var _self:ActivitesGroupLogic;
		/**
		 *一排最大的数量 
		 */		
		private const MAX_COUNT_EACH:int=8;
		/**一排最小数量**/
		private const MIX_COUNT_EACH:int = 4;
		private var _currentMaxCount:int=MAX_COUNT_EACH
		
		
		private const SHOW_FUNC:String="showFunc",HIDE_FUNC:String="hideFunc",FUNC:String="functio",PLIST:String="paramsList";
		private  var _registMap:Dictionary=new Dictionary;
		
		
		private const PIC:String="picName";
		private const SERVICE_ID:String="transition";
		private const INDEX:String="index";
		private const LEVEL:String="level";
		private const INFO:String="tipinfo";
		
		private const ID:String="ActivetyConfigID",EFFECT:String="effect",TEXT:String="texxxxxt";
		
		private const DATA:String="dataobj";
		
		private const FIG_HEAD:String="fig14";
		/**
		 *左右间距 
		 */		
		private const XOFF:int=75;
		
		
		/**
		 *BANK_ID	钱庄id 
		 * MONEY	俸禄
		 * GANG		门派
		 * GOLD:int=18 领取元宝
		 * STRIDE:int=33 跨服战 
		 * ChongZhiDaLiBao_ID:int=40 首次充值大礼包领取;
		 * 
		 */		
		public const BANK_ID:int=2,MONEY:int=15,GANG:int=16,WLYBGET_ID:int = 24,GOLD:int=18,STRIDE:int=33,ChongZhiDaLiBao_ID : int	= 40;		
		private var _xoff:Number=0;
		private var _yoff:Number=0;
		private var _bind:BindManage;
		private var _model:ModelLocator
		private var _role:RoleVo;
		private var _tip:TipsMainLogic;
		
		private var _ui:ActivitesGroupUI;
		private var _rollMc:MovieClip;
		
		private var _listArr:Array;
		
		/**
		 *当前需要显示的配置 
		 */		
		private var _currShowObjVec:Vector.<Object>;
		private var _currObjMap:Object;
		private var _currMcMap:Object;
		private var FLOW_ARR:Array=[MONEY,GANG,GOLD];
		
		private var FL_PROPERTIES:Array=[EFFECT,TEXT];
		
		private  const  	VIPType_ExchangeMoney:int			= 1;		// 钱庄换钱
		private  const  	VIPType_ResetBossClone:int			= 7;		// 重置精英副本
		private  const 	VIPType_BuySP:int					= 12;		// 购买体力
		private  const  	VIPType_WLYB_Savvy:int				= 38;		// 无量玉璧领取悟性
		private  var jtmc:MovieClip = ResManager.newResClass("custSkin_190") as MovieClip;
		public var exchangeMoney			:int 			= 0;
		public var buysp					:int			= 0;
		public var wlybSavvy				:int			= 0;
		//当前引导的活动ID
		private var guideIndex				:int			=	0;
		// 特殊活动 新手引导
		private var _specialIsOk:Boolean					= false ; 
		
		
		/**
		 *当前活动显示容器 
		 */		
		public static function getInstance():ActivitesGroupLogic
		{
			if(_self==null)
			{
				_self=new ActivitesGroupLogic();
			}
			return _self;
		}
		public function get ui():ActivitesGroupUI
		{
			if(_ui==null)
			{
				_ui=new ActivitesGroupUI
			}
			return _ui
		}
		public function  Init():void
		{
			_bind=BindManage.getInstance();
			_model=ModelLocator.getInstance();
			_role=_model.scene.Role;
			_tip=TipsMainLogic.instance;
			_currObjMap=new Object;
			_currShowObjVec=new Vector.<Object>;
			_currMcMap=new Object;
			_listArr=String(StaticIni.getIniVar("allAction","list")).split(",");
			var tempArr:Array = String(StaticIni.getIniVar("allFamilyAction","list")).split(",");
			var length:int = tempArr.length;
			for(var i:int = 0;i< length;i++){
				_listArr.push(tempArr[i]);
			}
			
			//			_ui.begin_one.visible=false;
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_ACTIVITY_STATE),onShow);
			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_GET_ONLINE_PRIZE_LEFT_TIME),getOnline);
			//钱庄？
			//			_model.addEventListener(String(CustomToClientFlag.SERVER_CUSTOMMSG_NEED_SELF_CAPITAL_EXCHANGE),onBank);
			//model.dispatchEvent(new SceneEvent(SceneEvent.SceneTransfer, null));
			//			BindManage.getInstance().BindProp(_model.scene.Role,"WLYBCanRewardTimes",this,"onsetWlybTimes");
			StageInfo.stage.addEventListener(Event.RESIZE,resize)
			//绑定于VIP有关的功能次数表格
			BindManage.getInstance().BindRecord(_model.scene,"VIPCountRec",addData,removeData);
			clear();
		}
		/**
		 * 活动界面 每个图标的位置 或者 换行
		 */		
		public function resize(e:Event):void
		{
			//			var themLength:int=currentMaxCount*XOFF;
			var top:BaseUI=TopPlayerLogic.getInstance()._ui;
			var width:Number = SceneChangeManager.getGameWidth() - TopPlayerLogic.getInstance()._ui.topPlayerBg.width - TaskTrackingUI.getInstance().width;
			if(TopOtherPlayerLogic.getInstance().ui.created)
			{
				width = width - TopOtherPlayerLogic.getInstance().ui.play_mc.width;
			}
			var count:int = width/80;
			if(count > MAX_COUNT_EACH)
			{
				currentMaxCount = MAX_COUNT_EACH;
			}else if(count < MIX_COUNT_EACH)
			{
				currentMaxCount = MIX_COUNT_EACH;
			}
			else
			{
				currentMaxCount = count;
			}
			
			//			if(TopPlayerLogic.getInstance()._ui.hitTestObject(_ui) && currentMaxCount > MIX_COUNT_EACH)
			//			{
			//				currentMaxCount--
			//			}
			//			else if(getX(top)+top.width+_ui.width+XOFF+1<=getX(_ui))
			//			{
			//				currentMaxCount++;
			//			}
			
			//			function getX(dis:DisplayObject):int
			//			{
			//				return dis.localToGlobal(new Point).x;
			//			}
		}
		
		private function set currentMaxCount(value:int):void
		{
			var i:int=Math.min(value,MAX_COUNT_EACH);
			if(_currentMaxCount!=i)
			{
				_currentMaxCount=i
				refreshUI()
			}
		}
		private function get currentMaxCount():int 
		{
			return _currentMaxCount;
		}
		public function set onsetWlybTimes(val:int):void
		{
			//			addCount(val  + WlybGetLogic.getInstance().wlybSavvy,WLYBGET_ID);
			addCount(val  + wlybSavvy,WLYBGET_ID);
		}
		
		public function	BeforeShow():void
		{
			addAllEventListener()
		}
		public function	AfterHide():void
		{
			removeAllEventListener()
		}
		public function addAllEventListener():void
		{
			_ui.begin_one.addEventListener(MouseEvent.CLICK,clickHandle);
			
			
		}
		/**
		 *全部的单机入口 
		 * @param e
		 * 
		 */		
		private function clickHandle(e:MouseEvent):void
		{
			if(!(GameData.Role.status == PlayerActionFlag.Sit))
			{
				GameData.Role.killMove();
			}	
			var dobj:DisplayObject	=	e.target as DisplayObject;
			var mc:MovieClip;
			if(dobj.parent==_ui.begin_one)
			{
				mc=dobj as MovieClip;
				//				if(mc	&&	mc[EFFECT])
				//					mc[EFFECT].visible=false
			}
			//			for (var i:int = 0; i < _ui.begin_one.numChildren; i++) 
			//			{
			//				var mc:MovieClip=_ui.begin_one.getChildAt(i);
			//				if(mc.contains(dobj))
			//				{
			//					break;
			//				}
			//			}
			//1 代表新的 悟性  第二个参数 1 代表次数
			
			if(mc)
				if(mc[DATA][ID] == 47)
				{
					SystemSender.getInstance().CustomMsg( int(CustomToServerFlag.CLIENT_CUSTOMMSG_GET_WLYB_REWARD),1 ,1);
				}else
				{
					SceneTransfer.getInstance().tranferTo(mc[DATA][SERVICE_ID]);
				}
			if(guideIndex == mc[DATA][ID] )
			{
				removeJtMc();
			}
			setLogClickNum(mc[DATA][ID])
		}
		public function removeAllEventListener():void
		{
			_ui.begin_one.removeEventListener(MouseEvent.CLICK,clickHandle)
			removeJtMc();
		}
		/**
		 *添加发光  
		 * @param id 活动id
		 * 
		 */		
		public function addEffect(id:int):void
		{
			var index:int=FLOW_ARR.indexOf(id);
			if(index==-1)
			{
				FLOW_ARR.push(id);
				var mc:MovieClip=_currMcMap[id];
				mcAddEffect(mc);
				//				refreshUI();
			}
		}
		/**
		 *删除发光 
		 * @param id
		 * 
		 */		
		public function removeEffect(id:int):void
		{
			var index:int=FLOW_ARR.indexOf(id);
			if(index!=-1)
			{
				FLOW_ARR.splice(index,1);
				var mc:MovieClip=_currMcMap[id];
				mcRemoveEffect(mc);
				//				refreshUI();
			}
		}
		
		public function removeJtMc():void
		{
			if(jtmc && jtmc.parent)
			{
				guideIndex = 0;
				jtmc.parent.removeChild(jtmc);
			}
		}
		
		public function addNewIconEffect(id:int):void
		{
			if(_currMcMap[id])
			{
				guideIndex = id;
				addEffect(id);
				var activitymc:MovieClip=_currMcMap[id];
				jtmc.x = -140;
				jtmc.play();
				activitymc.addChild(jtmc);
				if(activitymc.parent)
				{
					activitymc.parent.setChildIndex(activitymc,activitymc.parent.numChildren-1);
				}
				TweenLite.from(_currMcMap[id],3,{y:"-15", ease:Elastic.easeOut, overwrite:true, onComplete:blink});
				function blink():void
				{
					setTimeout(function():void{removeEffect(id)},2000);
				}
			}
		}
		
		/**
		 *给id的图标加上count的数字 
		 * @param count
		 * @param id
		 * 
		 */		
		public function addCount(count:int,id:int):void
		{
			if(FL_PROPERTIES.indexOf(id)==-1)
				FL_PROPERTIES.push(id);
			if(count<0)
			{
				count=0
			}
			if(id==2)
			{
				changeMax =count ; 
			}
			var obj:Object=_currObjMap[id];
			if(obj)
			{
				var mc:MovieClip=_currMcMap[obj[ID]];
				if(mc[id])
				{
					mc[id].parent.removeChild(mc[id])
				}
				var countStr:String=count+"";
				var countMc:MovieClip
				if(countStr.length>1)
				{
					countMc	=getCountMc()
				}
				else
				{
					countMc	=	ResManager.newResClass(FIG_HEAD+count) as MovieClip;
				}
				mc.addChild(countMc);
				mc[id]=countMc;
			}
			function getCountMc():MovieClip
			{
				var mcArr:Array=[];
				var mc1:MovieClip=new MovieClip;
				for (var i:int = 0; i < countStr.length; i++) 
				{
					mcArr[i]=ResManager.newResClass(FIG_HEAD+countStr.charAt(i)) as MovieClip;
					mcArr[i].x=mc1.width;
					mc1.addChild(mcArr[i]);
				}
				return mc1;
			}
		}
		//		private function onBank(e:CustomMsgEvent):void
		//		{
		//			var count:int=e.pList[0];
		//			addCount(count + WlybGetLogic.getInstance().exchangeMoney,BANK_ID)
		//		}
		/**
		 *检查 id显示 
		 * @return 
		 * 
		 */		
		public function checkIDshow(id:int):Boolean
		{
			var idName:String="action_"+id;
			var obj:Object=StaticIni.getIniObj(idName);
			return _currShowObjVec.indexOf(obj)>-1;
			
		}
		/**
		 *注册显示回调 //没用
		 * @param id
		 * @param showFunction
		 * @param closehandle
		 * @param plist
		 * 
		 */		
		public function registShowOrHideCallBack(id:int,showFunction:Function,closehandle:Function,plist:Array=null):void
		{
			var obj:Object;
			var callBack:Object
			var closeBack:Object;
			if(_registMap.hasOwnProperty(id))
			{
				obj	=	_registMap[id];
			}
			else
			{
				obj	=	_registMap[id]	=new Object;
				obj[SHOW_FUNC]=[];
				obj[HIDE_FUNC]=[];
				obj[PLIST]=[];
			}
			obj[SHOW_FUNC][obj[SHOW_FUNC].length]=showFunction;
			obj[HIDE_FUNC][obj[HIDE_FUNC].length]=closehandle;
			obj[PLIST][obj[PLIST].length]=plist;
		}
		/**
		 *如果后面两个参数都为空 则删除全部回调
		 * @param id
		 * @param showFunc
		 * @param closeFunc
		 * 
		 */		
		public function removeCallBack(id:int,showFunc:Function=null,closeFunc:Function=null):void
		{
			if(showFunc==null&&closeFunc==null)
			{
				delete _registMap[id];
			}
			else
			{
				var obj:Object=_registMap[id];
				if(obj[SHOW_FUNC]&&obj[SHOW_FUNC].length)
				{
					var showArr:Array=obj[SHOW_FUNC];
					var hideArr:Array=obj[HIDE_FUNC];
					var plistArr:Array=obj[PLIST];
					var index:int=showFunc!=null?showArr.indexOf(showFunc):hideArr.indexOf(closeFunc);
					if(index!=-1)
					{
						showArr.splice(index,1);
						hideArr.splice(index,1);
						plistArr.splice(index,1);
					}
				}
			}
		}
		private function callBack(id:int,state:String):void
		{
			var obj:Object=_registMap[id];
			if(obj&&obj[SHOW_FUNC]&&obj[SHOW_FUNC].length)
			{
				var targetArr:Array=obj[state]
				var plistArr:Array=obj[PLIST];
				var length:int=targetArr.length;
				for (var i:int = 0; i < length; i++) 
				{
					targetArr[i].apply(this,plistArr[i]);	
				}
			}
		}
		
		private var clipObj:Object = {};
		
		private function onShow(e:CustomMsgEvent):void
		{
			var sendIdArr:Array;
			var serviceArr:Array 					    = e.pList;
			var state					:int= serviceArr[0]; //是否创建新的活动
			var id						:int= serviceArr[1]; //活动ID
			var style					:int= serviceArr[2];//活动类型 2：全天 3：定时
			//			var isContain				:int= sendIdArr.indexOf(id);//过滤服务器重复发送同一消息
			var obj:Object;
			var idName:String="action_"+id;
			if(state==1)
			{
				obj=StaticIni.getIniObj(idName);
				if(obj==null)
				{
					//					trace("Error~ActivitesGroupLogic.onShow(e)",id);
					return 
					
				}
				if(_listArr.indexOf(idName)!=-1)
				{
					//					trace("ActivitesGroupLogic.onShow(e)","在当前列表里，不需要显示");
					return ;
				}
				if(_currShowObjVec.indexOf(obj)<0)
				{
					
					if(!clipObj[id])
					{
						clipObj[id] = ResManager.newResClass(obj[PIC]);
						
					}
					obj.PicClip = clipObj[id]
					_currShowObjVec.push(obj);
					_currObjMap[id]=obj
					if(id==BANK_ID)
					{
						//						trace("ActivitesGroupLogic.onShow(e)");
						//						setTimeout(function():void{
						
						SystemSender.getInstance().CustomMsg(CustomToServerFlag.CLIENT_CUSTOMMSG_NEED_SELF_CAPITAL_EXCHANGE,4,0)
						//						},1000);
					}
					if(id==STRIDE)
					{
						_model.addEventListener(LogicEvent.RESLOADED, function (e:LogicEvent):void
						{
							initStride();
						});
					}
					//回调
					//					callBack(id,SHOW_FUNC);
				}
			}
			else
			{
				obj=_currObjMap[id];
				if(obj&&_currShowObjVec.indexOf(obj)!=-1)
				{
					_currShowObjVec.splice(_currShowObjVec.indexOf(obj),1);
					//回调
					//					callBack(id,HIDE_FUNC);
				}
			}
			// 修改活动界面刷新 如果报错 删除这句话--
			if(obj == null)return  ; 
			//-------------------------------------
			refreshUI();
			if(id == WLYBGET_ID)
			{
				var wlybTimes:int = _model.scene.Role.GetPropertiesEx("WLYBCanRewardTimes");
				addCount(wlybSavvy,WLYBGET_ID);
			}
			if(!_ui.created)
			{
				var p:Point=new Point(RightTopIndexUI.getInstance().rightTopPanel.x-30,RightTopIndexUI.getInstance().rightTopPanel.y+10)
				//				ui.show(RightTopIndexUI.getInstance());
				_ui.x=p.x;
				_ui.y=p.y;
				ui.initPosX=p.x;
				ui.initPosY=p.y;
			}
			if(id == ChongZhiDaLiBao_ID)
			{
				addEffect(ChongZhiDaLiBao_ID);
			}
			//聚宝盆
			if(id == 42){
				addEffect(42);
			}
			if(id==45)
			{
				addEffect(45);
			}
			//钱庄兑换次数
			if(id==BANK_ID)
			{
				addCount(changeMax , BANK_ID);
			}

		}
		/**
		 * VIP 等级会改变 活动的兑换次数 
		 */		
		private function addData(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			var arr:Array = PropertiesValue;
			var type:int = arr[0];
			var useCount:int = arr[1];
			var allCount:int = arr[2];
			var cardCount:int = arr[3];
			
			switch (type)
			{
				//  1
				case VIPType_ExchangeMoney:
					exchangeMoney = allCount + cardCount - useCount;
					addCount(allCount + cardCount - useCount,BANK_ID);
					break;
				case VIPType_ResetBossClone:
					
					break;
				case VIPType_BuySP:
					TopPlayerLogic.getInstance()._spCount = useCount;
					TopPlayerLogic.getInstance()._addSpCount = allCount + cardCount;
					break;
				case VIPType_WLYB_Savvy:
					wlybSavvy = allCount + cardCount - useCount;
					addCount(allCount + cardCount - useCount,WLYBGET_ID);
					break;
			}
		}
		
		private function removeData(PropertiesName:String,PropertiesValue:Array,data:*):void
		{
			
		}
		/**
		 *初始化跨服战 
		 * 
		 */		
		private function initStride():void
		{
			//			trace("ActivitesGroupLogic.initStride()");
			StrideAttendLogic.getInstance().ui;
			StrideWarfareLogic.getInstance().ui;
			StrideMainLogic.getInstance().ui;
			StrideOtherWarfareLogic.getInstance().ui;
			StrideChipLogLogic.getInstance().ui
		}
		/**
		 *强制清除数据和显示 
		 * 
		 */		
		public function clear():void
		{
			_currObjMap=new Object;
			_currShowObjVec=new Vector.<Object>;
			_currMcMap=new Object
			clearVis()
		}
		public function refreshUI():void
		{
			sortData();
			clearVis();
			addVis()
		}
		
		/**
		 *清除显示 
		 * 
		 */		
		private function clearVis():void
		{
			while(_ui.begin_one.numChildren)
			{
				var mc:MovieClip=_ui.begin_one.removeChildAt(0) as MovieClip;
				if(mc)
				{
					mc.removeEventListener(MouseEvent.ROLL_OVER,rollOver);
					mc.removeEventListener(MouseEvent.ROLL_OUT,rollOut);
					McPool.returnRes(mc[DATA][PIC],mc);
					mc.x=0;
					mc.y=0;
					if(mc&&mc[EFFECT])
						mc[EFFECT]=false;
				}
			}
			_xoff=0;
			_yoff=0;
		}
		/**
		 *添加显示 
		 * 
		 */		
		private function addVis():void
		{
			var mc:MovieClip;
			for (var j:int = 0; j < _currShowObjVec.length; j++) 
			{
				var i:Object=_currShowObjVec[j];
				mc = i.PicClip//McPool.borrowRes(i[PIC]) as MovieClip//ResManager.newResClass(i[PIC]) as MovieClip;
				if(!mc)
				{
					//					trace("Error~ActivitesGroupLogic.addVis()没有这个资源",i[PIC]);
					continue ;
				}
				if(mc["effect1"] != null)
				{
					mc["effect1"].visible	=	false;
					mc["effect1"].stop();
				}
				mc.stop();
				mc[DATA]=i;
				_currMcMap[i[ID]]=mc;
				mc.mouseEnabled=true;
				mc.addEventListener(MouseEvent.ROLL_OVER,rollOver);
				mc.addEventListener(MouseEvent.ROLL_OUT,rollOut);
				if(FLOW_ARR.indexOf(int(i[ID]))!=-1)
				{
					mcAddEffect(mc);
				}
				else 
				{
					mcRemoveEffect(mc);
				}
				if(i.hasOwnProperty("cdShowID"))
				{
					addCDText(mc,i["cdShowID"]);
				}
				mc.mouseChildren=false;
				_ui.begin_one.addChild(mc);
				if(!(j%currentMaxCount))
				{
					_yoff=80*(j/currentMaxCount);
					_xoff=0;
				}
				mc.x=(_xoff-/*mc.width*/XOFF);
				_xoff	=mc.x;
				mc.y+=_yoff;
				//添加无量玉臂特效
				addTaskEffect(mc)
//				trace("ActivitesGroupLogic.addVis()",_xoff,mc.x,mc.y,mc.width,_currShowObjVec.length);
			}
			if(jtmc.parent)
			{
				jtmc.parent.parent.setChildIndex(jtmc.parent,jtmc.parent.parent.numChildren-1);
				jtmc.play();
			}
		}
		//添加无量玉臂特效
		private function addTaskEffect(mc:MovieClip):void
		{
			if(clipObj[23] == mc)
			{
				var mc_1:MovieClip = clipObj[23] ;
				if(_specialIsOk)
				{
					mc_1["pc"].visible = true ; 
					mc_1["pc"].play(); 
				}
				else
				{
					
					mc_1["pc"].visible = false  ; 
					mc_1["pc"].gotoAndStop(1)  ;
					mc_1["pc"].stop(); 
					
					for(var n:int = 0 ; n<getTest().length ; n++ )
					{
						var val:Array	=	(getTest() as Array)[n] ;
						if(val[0] == 4010)
						{
							mc_1["pc"].visible = true ; 
							mc_1["pc"].play(); 
						}
					}
					
				}
				
			}
		}
		private function addCDText(mc:MovieClip,cdId:int):void
		{
			if(!mc)return;
			//			trace("ActivitesGroupLogic.addCDText(mc, cdId)");
			if(mc[TEXT])
			{
				mc[TEXT].visible=true;
			}
			else
			{
				mc[TEXT]=new NxLabel;
				mc[TEXT+"flag"]=-1;
				mc[TEXT].htmlStr="00:00"
				mc[TEXT].y=mc.height-mc[TEXT].height;
				mc[TEXT].x=((mc.width-mc[TEXT].width)>>1)-7;
				mc.addChild(mc[TEXT]);
			}
			removeEffect(mc[DATA][ID]);
			mc[TEXT+"flag"]=	mc[TEXT+"flag"]==-1?PlayCDTimerLogic.getInstance().resgis(cdId,function (val:int,col:int=0):void{
				mc[TEXT].htmlStrByBorder	=	PlayCDTimerLogic.getInstance().getTimerStr(val);
				if(!val)
				{
					removeCDText(mc);
					addEffect(mc[DATA][ID]);
				}
			}):mc[TEXT+"flag"]
		}
		private function removeCDText(mc:MovieClip):void
		{
			
			if(!mc)return ;
			//			trace("ActivitesGroupLogic.removeCDText(mc)");
			if(mc[TEXT])
			{
				mc[TEXT].visible=false;
			}
			PlayCDTimerLogic.getInstance().removeResgin(mc[TEXT+"cd"],mc[TEXT+"flag"]);
			mc[TEXT+"flag"]=-1;
		}
		private function mcAddEffect(mc:MovieClip):void
		{
			if(!mc)return;
			if(!mc[EFFECT])
			{
				mc[EFFECT]= true;
				if(mc.effect1 == null)return
					mc["effect1"].play();
				mc["effect1"].visible	=	true;
			}
			else
			{
				mc["effect1"].visible	=	true;
				mc["effect1"].play()
			}
		}
		private function mcRemoveEffect(mc:MovieClip):void
		{
			if(!mc)return;
			if(mc[EFFECT])
			{
				mc[EFFECT]=false;
				mc["effect1"].visible	=	false;
				mc["effect1"].stop();
			}
		}
		public function set rollMc(value:MovieClip):void
		{
			if(_rollMc)
			{
				_rollMc.gotoAndStop(1)
			}
			_rollMc	=	value;
			if(_rollMc)
			{
				_rollMc.gotoAndStop(2);
			}
		}
		private var _currConfigID:String
		/**
		 *获取在线奖励 
		 */		
		private function getOnline(e:CustomMsgEvent):void
		{
			_currConfigID = String(e.pList[0]);
		}
		private function rollOver(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			//			trace("ActivitesGroupLogic.rollOver(e)",mc.width,mc.height);
			rollMc=mc;
			for each (var i:String in FL_PROPERTIES) 
			{
				if(mc	&&	mc[i] && mc[i] is DisplayObject)
				{
					mc.setChildIndex(mc[i],mc.numChildren-1);
				}
			}
			if(mc[DATA]["ActivetyConfigID"]==41)
			{
				_tip.showMain(StaticIni.getSwfLangStrVar(String(mc[DATA][INFO]),[StaticIni.getSwfLangStr(_currConfigID)]));
				_model.dispatchEvent(new SoundEvent(SoundEvent.MOUSE_OVER));
				return;
			}
			_tip.showMain(StaticIni.getSwfLangStr(mc[DATA][INFO]));
			_model.dispatchEvent(new SoundEvent(SoundEvent.MOUSE_OVER));
		}
		private function rollOut(e:Event):void
		{
			var mc:MovieClip=e.currentTarget as MovieClip;
			mc.gotoAndStop(1)
			//			mc["effect1"].visible	=	false;
			//			mc["effect1"].stop();
			for each (var i:String in FL_PROPERTIES) 
			{
				if(mc	&&	mc[i] && mc[i] is DisplayObject)
				{
					mc.setChildIndex(mc[i],mc.numChildren-1);
				}
			}
			_tip.hide();
		}
		/**
		 *排序 
		 */		
		private function sortData():void
		{
			_currShowObjVec.sort(compare);
			function compare(x:Object,y:Object):Number
			{
				return x.index-y.index
			}
		}
		/**
		 * 对应按钮的点击次数 
		 * @param clickType
		 * 
		 */		
		private function setLogClickNum(clickType:int):void
		{
			switch(clickType)
			{
				case 11:
					LogSendLogic.getInstance().btnClickNumSend(22126);
					break;
				case 10:
					LogSendLogic.getInstance().btnClickNumSend(22127);
					break;
				case 9:
					LogSendLogic.getInstance().btnClickNumSend(22128);
					break;
				case 7:
					LogSendLogic.getInstance().btnClickNumSend(22129);
					break;
				case 6:
					LogSendLogic.getInstance().btnClickNumSend(22130);
					break;
				case 3:
					LogSendLogic.getInstance().btnClickNumSend(22131);
					break;
				case 2:
					LogSendLogic.getInstance().btnClickNumSend(22132);
					break;
				case 1:
					LogSendLogic.getInstance().btnClickNumSend(22133);
					break;
				case 14:
					LogSendLogic.getInstance().btnClickNumSend(22134);
					break;
				case 12:
					LogSendLogic.getInstance().btnClickNumSend(22135);
					break;
				case 15:
					LogSendLogic.getInstance().btnClickNumSend(22136);
					break;
				case 8:
					LogSendLogic.getInstance().btnClickNumSend(22137);
					break;
				
			}
		}
		private var _changeMax:int  ; 
		public function set  changeMax(value:int):void 
		{
			_changeMax = value; 
		}
		public function get changeMax():int
		{
			return _changeMax ; 
		}
		/**
		 * 当前接任务的表格
		 */		
		private function  getTest():Array
		{
			if(_model.scene.GetPropertiesEx("Task_Accepted"))
			{
				return  (_model.scene.GetProperties("Task_Accepted") as Record).recArr  ;
			}
			return [] ; 
		}
		public function updateActivites(id:int):void
		{
			switch(id)
			{
				case 23:
					if(!clipObj[id])
					{
						return  ; 
					}
					var mc:MovieClip = clipObj[id] ;
					if(_specialIsOk)
					{
						mc["pc"].visible = true ; 
						mc["pc"].play(); 
					}
					else
					{
						mc["pc"].visible = false  ; 
						mc["pc"].gotoAndStop(1)  ;
						mc["pc"].stop(); 
					}
					break ; 
			}
		}
		public function set sepcialIsOk(boolean:Boolean):void
		{
			_specialIsOk = boolean ; 
		}
		public function get sepcialisOk():Boolean
		{
			return _specialIsOk ;
		}
		public function openUI(id:int):Boolean
		{
			if(!_currObjMap[id])
			{
				for(var n:int = 0 ; n<getTest().length ; n++ )
				{
					var val:Array	=	(getTest() as Array)[n] ;
					if(val[0] == 4010)
					{
						return true ;
					}
				}
			}else
			{
				return  true ; 
			}
			
			return false ; 
		}
		
	}
}